package com.letv.work.cp_info;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.letv.bean.SummaryBean;
import com.letv.work.JobInterface;

/**
 * CP business offline task work class
 */
public class CpInfoWorker implements Runnable {

    /**
     * Logger
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(CpInfoWorker.class);

    /**
     * String, the name of this worker
     */
    private static final String WORKER_NAME = "cp_info";

    /**
     * run thread
     */
    @Override
    public void run() {
        LOGGER.info("begin work " + CpInfoWorker.WORKER_NAME + "...");
        try {
            Thread.currentThread().setName(CpInfoWorker.WORKER_NAME);
            JobInterface job = new CpInfoJob();
            SummaryBean jobSummary = job.doJob(CpInfoWorker.WORKER_NAME);
            if(!StringUtils.isBlank(jobSummary.getErrorMsg())) {
                LOGGER.info("summary error message is " + jobSummary.getErrorMsg());
            }
        } catch(Exception e) {
            LOGGER.error("fail to run CpInfoWorker", e);
        }
    }
}
